package com.wuhainan.beelzebub.controller.system;

import com.wuhainan.beelzebub.entity.system.CategoryType;
import com.wuhainan.beelzebub.service.system.CategoryTypeService;
import com.wuhainan.beelzebub.utils.PageInfo;
import com.wuhainan.beelzebub.utils.TableData;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <br>Created by 吴海南 on 2017-12-18.
 * <br>星期一 at 上午 10:11.
 */
@RestController
@RequestMapping("api")
public class CategoryTypeController {
    @Resource
    private CategoryTypeService categoryTypeService;
    @RequestMapping("categoryTypePage")
    public TableData CategoryTypePage(PageInfo pageInfo, CategoryType categoryType){
        return categoryTypeService.findCategoryTypePage(pageInfo,categoryType);
    }
    @RequestMapping("categoryType")
    public List<CategoryType> CategoryTypePage(){
        return categoryTypeService.findAll();
    }
    @RequestMapping("categoryType/{id}")
    public CategoryType categoryType(@PathVariable String id) {
        return categoryTypeService.findCategoryTypeById(id);
    }

    @RequestMapping("saveCategoryType")
    public void saveCategoryType(@RequestBody CategoryType categoryType) {
        categoryTypeService.saveCategoryType(categoryType);
    }

    @RequestMapping("deleteCategoryType")
    public void deleteCategoryType(@RequestBody CategoryType categoryType) {
        categoryTypeService.deleteCategoryType(categoryType);
    }

}
